﻿@using StackExchange.Opserver.Data.Dashboard
@model Node
@{
    Layout = null;
    var h = Model.Hardware;
}
<h4 class="modal-title">
    @Model.PrettyName Hardware
</h4>
<div class="row small">
    <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">Processors</div>
            <div class="panel-body">
                <ul class="ul-plain">
                    @foreach (var p in h.Processors)
                    {
                        <li>
                            <span class="text-muted">@p.Name:</span> @p.Description
                        </li>
                    }
                </ul>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">Memory</div>
            <div class="panel-body">
                @{
                    var banks = h.MemoryModules.GroupBy(m => m.Bank).ToList();
                    var cols = banks.Count > 1 ? "6" : "12";
                    foreach (var b in banks)
                    {
                        <div class="col-md-@cols">
                            <h6>Bank @b.Key</h6>
                            <ul class="ul-plain">
                                @foreach (var m in b.OrderBy(m => m.Label))
                                {
                                    <li>@m.IconSpan() <span class="text-muted">@m.PrettyName:</span> @m.Size</li>
                                }
                            </ul>
                        </div>
                    }
                }
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">Temps</div>
            <div class="panel-body">
                <ul class="ul-plain">
                    @foreach (var t in h.Temps)
                    {
                        <li>
                            <span class="text-muted">@t.Name:</span> @t.Celsius.ToString(CultureInfo.CurrentUICulture) °C
                        </li>
                    }
                </ul>
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">Storage</div>
            <div class="panel-body">
                @if (h.Storage.Controllers.Any())
                {
                    foreach (var c in h.Storage.Controllers)
                    {
                        <div>@c.IconSpan() @c.Name <span class="@c.MonitorStatus.TextClass(true)">(@c.State)</span></div>
                        <ul class="ul-tree">
                            <li><span class="text-muted">Driver:</span> @c.DriverVersion</li>
                            <li><span class="text-muted">Firmware:</span> @c.FirmwareVersion</li>
                        </ul>
                    }
                }
                @if (h.Storage.VirtualDisks.Any())
                {
                    foreach (var d in h.Storage.VirtualDisks)
                    {
                        <div>@d.IconSpan() Virtual Disk: @d.Name</div>
                    }
                }
                @if (h.Storage.PhysicalDisks.Any())
                {
                    foreach (var d in h.Storage.PhysicalDisks)
                    {
                        <div>@d.IconSpan() @d.Name <span class="text-muted">(@d.Media)</span></div>
                        <ul class="ul-tree">
                            <li><span class="text-muted">Id:</span> @d.ProductId</li>
                            <li><span class="text-muted">Serial:</span> @d.Serial</li>
                            <li><span class="text-muted">Capacity:</span> @d.Capacity</li>
                            <li><span class="text-muted">Speed:</span> @d.NegotatiedSpeed/@d.CapableSpeed</li>
                        </ul>
                    }
                }
            </div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">Components</div>
            <div class="panel-body">
                <ul class="ul-plain">
                    @foreach (var t in h.Components)
                    {
                        <li>
                            @t.IconSpan() @t.Name
                        </li>
                    }
                </ul>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">Power Supplies</div>
            <div class="panel-body">
                    @foreach (var p in h.PowerSupplies)
                    {
                        <div>@p.IconSpan() @p.Name</div>
                        <ul class="ul-tree">
                            <li><span class="text-muted">Amps:</span> @p.Amps.ToString(CultureInfo.CurrentUICulture)</li>
                            <li><span class="text-muted">Volts:</span> @p.Volts.ToString(CultureInfo.CurrentUICulture)</li>
                            <li><span class="text-muted">Input (Rated):</span> @p.RatedInputWattage</li>
                            <li><span class="text-muted">Output (Rated):</span> @p.RatedOutputWattage</li>
                        </ul>
                    }
            </div>
        </div>
    </div>
</div>